import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import resolveExternalsPlugin from 'vite-plugin-resolve-externals';
import Components from 'unplugin-vue-components/vite'
import IoUIResolver from 'plugin-vue-components/resolver'
function pathResolve(dir: string) {
    return resolve(process.cwd(), '.', dir);
}
// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        resolveExternalsPlugin({
            AMap: 'AMap',
        }),
        Components({
            resolvers: [
                IoUIResolver(),
            ],
        })
    ],
    resolve: {
        alias: [
            {
                find: /\/@\//,
                replacement: pathResolve('src') + '/',
            },
        ],
        extensions: ['.js', '.ts', '.mjs', '.vue', '.json', '.less', '.css'],
    },
    server: {
        host: true,
        https: false,
    },
    optimizeDeps: {
        esbuildOptions: {
            target: 'es2020',
        },
        // @iconify/iconify: The dependency is dynamically and virtually loaded by @purge-icons/generated, so it needs to be specified explicitly
        include: ['lodash-es', 'ant-design-vue/es/locale/zh_CN', 'ant-design-vue/es/locale/en_US'],
    },
});
